package com.liss.lissaiagent.demo.invoke;


import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @Author: Mr.Li
 * @CreateTime: 2025-10-09
 * @Description: springAI 框架调用AI大模型
 * @Version: 1.0
 */
@Component
public class SpringAiInovke implements CommandLineRunner {

    @Resource
    private ChatModel dashscopeChatModel;


    @Override
    public void run(String... args) throws Exception {
        AssistantMessage result = dashscopeChatModel.call(new Prompt("你好，我是一名java程序员"))
                .getResult()
                .getOutput();
        System.out.println(result.getText());
    }
}
